package com.tidc.seaserverservice.util;

import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * @author ：冯涛滔
 * @date ：Created in 2020-4-13 19:27
 * @description：
 * @modified By：
 * @version:
 */
public class StringUtil {
    /** 冒泡降序排序 **/
//    public static void descSort2(List<Company> companies) {
//        int in, out;
//        Company temp = null;
//        for (out = 0; out < companies.size(); out++) {
//            for (in = companies.size() - 1; in > out; in--) {
//                if (companies.get(in).getHeat() > companies.get(in-1).getHeat()) {
//                    temp = companies.get(in);
//                    companies.set(in,companies.get(in-1));
//                    companies.set(in-1,temp);
//                }
//            }
//        }
//    }
//    /** 冒泡降序排序 **/
//    public static void descSort(List<Position> companies) {
//        int in, out;
//        Position temp = null;
//        for (out = 0; out < companies.size(); out++) {
//            for (in = companies.size() - 1; in > out; in--) {
//                if (companies.get(in).getHeat() > companies.get(in-1).getHeat()) {
//                    temp = companies.get(in);
//                    companies.set(in,companies.get(in-1));
//                    companies.set(in-1,temp);
//                }
//            }
//        }
//    }
    public static List<String> stringToList(String s){
        if(s!=null){
            List<String> list = Arrays.asList(s.split(","));
            return list;
        }
        return null;

    }
    public static String listToString(List<String> list){
        if(list!=null){
            return StringUtils.join(Arrays.asList(list.toArray()), ",");
        }
        return null;

    }
    public static String removalUri(String s){
        s = s.substring(s.indexOf("photo/"));
        s = s.substring(s.indexOf("/")+1);
        return s;
    }

//    public static void main(String[] args) {
//        String path = "http://gz.pwbov.cn/photo/8888/625c38492f744a7f8d9335d9e9ec7050.zip";
//        int i = path.lastIndexOf(".");
//        String substring = path.substring(i);
//        System.out.println(substring);
//    }

}
